In recent years, there has been an increase in the use of electronic devices such as mobile phones, laptops. Personal Digital Assistants (PDAs), Automatic Teller Machines (ATMs), microwave ovens. Programmable Logic Controllers (PLCs), pagers, oscilloscopes, routers, and wired phones. These electronic devices have a recording medium or a storage space, referred to as memory, to store information that can be used in the future. Examples of the memory include, but are not limited to, Random Access Memory (RAM), Read Only Memory (ROM), and cache memory. One or more applications can be implemented on the electronic device to perform various functions. Examples of the one or more applications include Bluetooth, infrared, a camera, a voice recorder, and a calculator.
Typically, an electronic device allocates a predefined amount of memory to an application at the start-up stage of the electronic device. Such a memory allocation is referred to as a static memory allocation. The statically allocated memory is divided into one or more memory pools. Each of the one or more memory pools is further divided into one or more fixed-size blocks. A memory allocator, which is part of a computer program, accepts requests for memory allocation from the one or more applications present at the electronic device. The memory allocator allocates fixed-size memory blocks to the one or more applications on a need basis. The fixed-size memory block can be greater than or equal to the requested size of the memory requested by the one or more applications. Further, the memory allocator marks such a fixed-size memory block as in-use. A fixed-size block for an application, if marked in-use by the memory allocator, cannot be re-allocated to any other application till the time it is used by the application.
The number and size of the memory requests from an application depends on the protocol that is being used. In static memory allocation, memory is allocated to the application at the start-up of the electronic device, and therefore, remains unchanged until the electronic device is restarted. Typically, the one or more memory pools and the one or more fixed-size memory blocks are allocated such that none of the applications of the one or more applications runs short of memory. For example, the memory allocator of the electronic device allocates a fixed-size (1500 bytes) memory block for a web browser application using the Transmission Control Protocol/Internet Protocol (TCP/IP) protocol. However, the web browser may not use all the memory that is allocated to it which results in memory wastage. Further, when there is a change in the application requesting fixed-size memory blocks from the electronic device, the fixed-size memory block that was assigned at the start-up of the electronic device is allocated to the new application. For example, when the application changes from a web browser application using TCP/IP (packet size 1500 bytes) to a Voice over Internet Protocol (VoIP) application using Real-Time Transport Protocol/User Datagram Protocol/Internet protocol (RTP/UDP/IP), which requires only a 66-byte packet size for G.723.1 and a 200-byte total for a G.729a codec, the allocated memory is not utilized fully, since the VoIP application requires a fixed-size block of 66 bytes only, as compared to the 1500-byte packet size allocated to it.
Hence, there is a need for a method that enables efficient use of memory while allocating fixed-size memory blocks to the allocation requests of the one or more applications present at the electronic device.
Skilled artisans will appreciate that elements in the figures are illustrated for simplicity and clarity and have not necessarily been drawn to scale. For example, the dimensions of some of the elements in the figures may be exaggerated, relative to other elements, to help in improving an understanding of embodiments of the present invention.